package org.crackjack.android.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

public class HttpClient extends DefaultHttpClient {

    public String makeGetRequest(String url) throws ClientProtocolException, IOException {
        HttpGet getRequest = new HttpGet(url);
        HttpEntity entity = null;
        HttpResponse response = null;

        response = execute(getRequest);
        BufferedReader reader = null;
        StringBuilder builder = new StringBuilder();

        try {
            String line;
            reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
            while ((line = reader.readLine()) != null) {

                builder.append(line);
            }

            return builder.toString();
        } finally {
            if (reader != null) {
                reader.close();
            }
        }
    }

}
